package com.china08.yxyapi.api.manage.tec.teaching.weikecheng.weike;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.yxweike.YxyWeikeService;
import com.china08.yxyapi.util.EsResourceUpdateUtil;

/**
 * 老师---我的微课 删除
 * 
 */
@CrossOrigin
@RestController
public class WeikechengDelController extends YxyApiBaseController {

    @Autowired
    private YxyWeikeService weikeService;

    @RequestMapping(value = "/api_yw/manage/tec/teaching/weikecheng/weike", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response,
            @RequestParam(value = "weikeId") String weikeId, RespModel respModel) {
        weikeService.delete(weikeId);
        // 重建索引
        EsResourceUpdateUtil.updateEsResoure(weikeId);
        respModel = new RespModel();
        respModel.setMessage("删除成功");
        return respModel;
    }

    protected static class RespModel extends YxyApiRespModel {

    }
}